﻿using IntelligentAgriculture.Contracts.Interface.IManagements;
using IntelligentAgriculture.WebAPI.Application.Command.ManageCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.ManageCommandHandler
{
    public class ManageUpdateCommandHander : IRequestHandler<ManagerUpdateCommand, Results<int>>
    {

        private readonly IManageService _manageService;

        public ManageUpdateCommandHander(IManageService manageService)
        {
            _manageService = manageService;
        }



        /// <summary>
        /// 执行耳标修改操作
        /// </summary>
        /// <param name="request">包含耳标修改所需的请求信息</param>
        /// <param name="cancellationToken">用于取消操作的令牌</param>
        /// <returns>返回一个表示耳标修改操作结果的任务</returns>
        public async Task<Results<int>> Handle(ManagerUpdateCommand request, CancellationToken cancellationToken)
        {
            int result = await _manageService.Update(request.ManagerInput);
            return Results<int>.DataResult(result);
        }
    }
}
